package exercise.no2;

import java.util.*;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-24
 */
public class Test {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        list.add(new Car("奥迪", 1000));
        list.add(new Car("奥特曼", 200));
        list.add(new Car("奥拓", 300));
        System.out.println(list);

/*        System.out.println(list.contains(new Car("奥特曼", 100)));
        list.remove(1);
        System.out.println(list);
        System.out.println(list.contains(new Car("奥特曼", 100)));*/

/*        System.out.println(list.size());
        System.out.println(list.isEmpty());
        list.clear();
        System.out.println(list.isEmpty());*/

        ArrayList cp = new ArrayList();
        cp.addAll(list);
        for (Object o : cp) {
            System.out.println(o);
        }

        System.out.println();
        list.remove(1);
        cp.removeAll(list);
        Iterator it = cp.iterator();
        while (it.hasNext()) {
            Car obj = (Car)it.next();
            System.out.println(obj);
        }
        list.addAll(cp);
        System.out.println(list.containsAll(cp));
    }
}
